package DBLayer;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;

import ModelLayer.SalesOrder;


public class OrderDB {
	
	private  Connection con;
	
	
	public OrderDB()
	{
		con = ConnectionDB.getInstance().getDBcon();
	}
	
	public void addSalesOrder(SalesOrder o)
	{
		String query = "INSERT into Order values ('"+o.getDate()+"',"+o.getDeliveryStatus()+"', '"+o.getDeliveryDate()+"','"+o.getRentTime()+"', 1)";
		
		try
    	{
    		Statement stmt = con.createStatement();
    		stmt.setQueryTimeout(5);
    		ConnectionDB.startTransaction();
    		stmt.executeUpdate(query);
    		ConnectionDB.commitTransaction();
    		
    		
    	}
    	catch (SQLException e)
    	{
    		ConnectionDB.rollbackTransaction();
    	}
    }
	

}
